home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Applications
/
PICSee Dust 1.01
/
Quaternary Source
/
GraphicsBuffers.h
< prev
next >
Wrap
Text File
|
1995-11-24
|
8KB
|
313 lines
/*
GraphicsBuffer.h header file
by Hiep Dam
Version 4.0
Last update: Nov 1995
Copyright ©1995 by Hiep Dam, All Rights Reserved
You may freely use the GraphicsBuffers source files
in your own applications.
This header file is cross-platform compatible. You may use this same
header file for all the supported platforms (currently only Macintosh).
*/
// ===========================================================================
#ifndef GRAPHICSBUFFERS_H_
#define GRAPHICSBUFFERS_H_
#ifndef CP_DATA_H_
#include "CP_Data.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
// ===========================================================================
/*
These are the pixel copying routines currently supported by
GraphicsBuffers.
*/
enum {
kPixelCopyRectMethod, // No mask used.
kPixelCopyMaskMethod, // A 1-bit B&W mask is used.
kPixelCopyTransparentMethod, // Transparent color as "mask", no real mask.
kPixelCopyRegionMethod, // Region as a mask.
kBlitterRectMethod,
kBlitterTransparentMethod,
kBlitterDeepMaskMethod // Mask same depth as src buffer.
};
// ---------------------------------------------------------------------------
// GraphicsBuffers types
enum {
kGraphicsBuffer,
kVideoMemoryBuffer // A graphics buffer equivalent for the monitor
};
// GraphicsBuffers flags (used in NewGraphicsBuffer, UpdateGraphicsBuffer, etc)
enum {
kGBOptimalFlag = 0
};
// ---------------------------------------------------------------------------
typedef short GBErr;
// Supported error codes
enum {
kGBNoErr = 0,
kGBNoMemAvailErr = 1972,
kGBParamErr,
kGBOSErr // Error from operating system
};
// ---------------------------------------------------------------------------
/*
The GraphicsBuffer structure is now private and internal to the
specific implementations of GraphicsBuffers. The GraphicsBufferPtr
is an opaque pointer; you should not dereference it.
*/
typedef void *GraphicsBufferPtr;
/*
GraphicsEnvironment.
The fields are private and not to be handled directly, but are
declared here like this so the compiler knows the size of
the GraphicsEnvironment structure.
*/
typedef struct {
void *reserved0;
void *reserved1;
} GraphicsEnvironment, *GraphicsEnvPtr;
/*
These defines are most useful if you use double-buffering animation
in your programs. There are three distince steps in double-buffering,
and the function pointers here define those steps.
ImageEraser -> Copy bkgnd patch & put it onto temp buffer
ImageDrawer -> Draw sprite (masked) over bkgnd patch in temp buffer
Depending on the drawer, typecasted MaskPtr could be either a
RgnHandle (Macintosh) or a GraphicsBufferPtr
ImageRefresher -> Copy this updated patch from temp buffer to screen
*/
typedef void *MaskPtr; // Macintosh: either a RgnHandle or a GraphicsBufferPtr
// Windows: either a HRGN or a GraphicsBufferPtr
typedef void (*ImageEraser)(GraphicsBufferPtr, GraphicsBufferPtr,
const CP_Rect*, const CP_Rect*);
typedef void (*ImageDrawer)(GraphicsBufferPtr, GraphicsBufferPtr,
const CP_Rect*, const CP_Rect*, MaskPtr);
typedef ImageEraser ImageRefresher;
// ===========================================================================
/*
Make sure you call InitGraphicsBuffer() before calling any other
routines in here!
*/
GBErr InitGraphicsBuffers();
/*
GraphicsBuffer creation, deletion, utility calls. Most of these
are fashioned after similar GWorld (Macintosh) calls.
*/
GBErr NewGraphicsBuffer(
GraphicsBufferPtr *buffer,
CP_ULong pixelDepth,
const CP_Rect *boundsRect,
CP_ULong flags,
CP_ULong cache);
GBErr UpdateGraphicsBuffer(
GraphicsBufferPtr buffer,
long pixelDepth,
const CP_Rect *boundsRect,
long flags,
long cache);
GBErr DisposeGraphicsBuffer(GraphicsBufferPtr buffer);
GBErr Convert2GraphicsBuffer(
GraphicsBufferPtr *buffer,
CP_Window_Ref srcWind,
const CP_Rect *bounds,
long cache);
void SetGraphicsBuffer(const GraphicsBufferPtr buffer);
void SetGraphicsEnvironment(const GraphicsEnvPtr environs);
void GetGraphicsEnvironment(GraphicsEnvPtr environs);
Boolean LockGraphicsBuffer(const GraphicsBufferPtr buffer);
void UnlockGraphicsBuffer(const GraphicsBufferPtr buffer);
// ---------------------------------------------------------------------------
// Get/Set Routines
long GetGraphicsBufferType(GraphicsBufferPtr buffer);
long GetGraphicsBufferDepth(GraphicsBufferPtr buffer);
void *GetGraphicsBufferPixelAddress(GraphicsBufferPtr buffer);
unsigned long GetGraphicsBufferRowBytes(GraphicsBufferPtr buffer);
void GetGraphicsBufferBounds(GraphicsBufferPtr buffer, CP_Rect *globalBounds);
void SetGraphicsBufferTransferMode(short newMode);
short GetGraphicsBufferTransferMode();
#ifdef __Macintosh_Platform__
#ifndef __QDOFFSCREEN__
#include <QDOffscreen.h>
#endif
GWorldPtr GetGraphicsBufferGWorld(GraphicsBufferPtr buffer);
#endif
// ---------------------------------------------------------------------------
/*
Pixel copying calls.
*/
// Uses standard operating system calls (Macintosh-> CopyBits)
// Uses kPixelCopyRectMethod
void CopyGraphicsBuffer(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR);
// Explicit source or destination.
// Uses kPixelCopyRectMethod
void CopyGraphicsBuffer2Window(
GraphicsBufferPtr srcBuffer,
CP_Window_Ref destWind,
const CP_Rect *srcR,
const CP_Rect *destR);
// Uses kPixelCopyRectMethod
void CopyWindow2GraphicsBuffer(
CP_Window_Ref srcWind,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR);
// Uses kPixelCopyRegionMethod
void CopyGraphicsBufferRegion(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR,
CP_Region_Hdl maskRgn);
// Uses kPixelCopyMaskMethod
void CopyGraphicsBufferMask(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR,
GraphicsBufferPtr maskBuffer);
// Uses kPixelCopyTransparentMethod
void CopyGraphicsBufferTransparent(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR,
GraphicsBufferPtr _notUsed);
// ---------------------------------------------------------------------------
// Uses custom pixel-blitting routines (8-bit only)
// Uses kBlitterRectMethod
void BlitGraphicsBuffer_8bit(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR);
// Uses kBlitterDeepMaskMethod
void BlitGraphicsBuffer_Mask8bit(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR,
GraphicsBufferPtr maskBuffer);
// Uses kBlitterTransparentMethod
void BlitGraphicsBuffer_Transparent8bit(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR,
GraphicsBufferPtr _notUsed);
// 4-bit blitters
// Uses kBlitterRectMethod
void BlitGraphicsBuffer_4bit(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR);
// Uses kBlitterDeepMaskMethod
void BlitGraphicsBuffer_Mask4bit(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR,
GraphicsBufferPtr maskBuffer);
// 16-bit blitters
// Uses kBlitterRectMethod
void BlitGraphicsBuffer_16bit(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR);
// Uses kBlitterTransparentMethod
void BlitGraphicsBuffer_Transparent16bit(
GraphicsBufferPtr srcBuffer,
GraphicsBufferPtr destBuffer,
const CP_Rect *srcR,
const CP_Rect *destR,
GraphicsBufferPtr _notUsed);
// ===========================================================================
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // GRAPHICSBUFFERS_H_